import { UserService, ArticleService } from '../../../services'

const Home = {
  namespaced: true,
  state: {
    userLabelList: [],
    userInformation: {}
  },
  mutations: {
    setUserLabelList(state, payload) {
      state.userLabelList = payload
    },
    setUserInformation(state, payload) {
      state.userInformation = payload
    }
  },
  actions: {
    async getUserLabelList(ctx) {
      const res = await UserService.getLabelList({ offset: 0, limit: 100 })
      ctx.commit('setUserLabelList', res.data)
    },
    async getUserInformation({ commit }) {
      const res = await ArticleService.getUserInfo()
      commit('setUserInformation', res.data.result)
    }
  }
}
export default Home
